home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
database
/
sr_info.exe
/
BIT.PRG
< prev
next >
Wrap
Text File
|
1990-04-11
|
1KB
|
35 lines
*** BIT.PRG ***
** A demonstration program provided by SUB ROSA PUBLISHING INC.
** (C) Copyright 1990, Sub Rosa Publishing Inc.
** This program may be copied freely. If it is used in commercial code,
** please credit the source, Sub Rosa Publishing Inc.
**
** BIT demonstrates the use of bit( ) function to generate the binary
** code for characters.
** BIT is compatible with all current versions of SR-Info and VP-Info.
**
**
** Sid Bursten and Bernie Melman
** April, 1990
*
SET RAW ON ; eliminates spaces between listed output
DO WHILE t ; perpetual loop terminated by BREAK command
ACCEPT 'Enter a short string for binary representation: ' TO string
IF string=' '
BREAK
ENDIF
?
REPEAT (LEN(string)*8) TIMES VARYING position ; 8 bits * number of chars
BIT_VAL = IFF(BIT(string,position),1,0) ; note use of IFF( ) function
?? str(bit_val,1,0) ; .. and STR( ) to format output
IF MOD(position,8)=0 ; .. and MOD( ) to space between characters
IF col()>60
?
ELSE
?? ' '
ENDIF
ENDIF
ENDREPEAT
ENDDO
*** end of BIN.PRG ***